﻿module Iteration
type matrix = float list list

/// Iteration solve function
let solve step enough x =
  let rec loop x =
    match step x with
    | x_next when enough x_next x -> x_next
    | x_next -> loop x_next
  loop x

let det (m: matrix) = m.[0].[0] * m.[1].[1] - m.[0].[1] * m.[1].[0]
let cramer2x2 (m: matrix) = 
  let d = det [m.[0]; m.[1]]
  let d1 = det [m.[2]; m.[1]]
  let d2 = det [m.[0]; m.[2]]
  [d1 / d; d2 / d]